<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>添加信息</title>
  <script>
    function addContinue(){
    	
    }
    window.onload = function () {
    	if ("${type}" == "self") {
    		document.getElementById("back").style.display="none";
    	}
    }
    function submit() {
    	document.getElementById("form").submit();
    }
    
  </script>
</head>
<body>
  <form id="form" action="StudentServlet?action=addStudent" method="post">
    <input type="hidden" name="type" value="${type}">
    <input type="hidden" name="id" value="${student.id }">
	<table id="table">
	<%List<Map<String, Object>> properties = (List<Map<String, Object>>) request.getAttribute("properties"); 
    Map<String, Object> student  = (Map<String, Object>) request.getAttribute("student");%>
        <%for (Map<String, Object> property : properties) {
            String propertyName = property.get("property") != null ? property.get("property").toString() : "";
            String studentProperty = "";
            if (student != null) {
                studentProperty = student.get(propertyName) != null ? student.get(propertyName).toString() : "";
            }%>
      <tr>
        <td><%=property.get("name") %>：</td>
        <td><input name="<%=propertyName%>" value="<%=studentProperty%>"></td>
      </tr>
        <%}%>
	</table>
	<!-- <a onclick="addContinue">继续添加</a><br> -->
	<c:if test="${type=='self'}">
	  <div>
	    <a>设置个人默认首页：</a>
	    <select name="homepage" class="font-size:15px;">
	      <option value="userInfo">个人信息</option>
          <c:forEach var="role" items="${roleList}">
            <option value="${role.id}">${role.role}信息</option>
          </c:forEach>
          <c:if test="${fn:contains(right, 'x;')}">
            <option value="manager">系统管理</option>
          </c:if>
	    </select>
	  </div>
      <div><a href="UserServlet?action=modifyPassword">修改密码</a></div>
    </c:if>
	<input type="hidden" name="role" value="${role}"/>
	<a href="javascript:submit()">确认</a>
	<a id="back" href="javascript:history.go(-1)">返回</a>
  </form>
</body>
</html>